import queue
import time

def consumer(name):
    print('-------start eat baozi---------')
    while True:
        new_baozi = yield
        print('[%s]is eating baozi %s' % (name, new_baozi))

def producer():
    r = con.__next__()  #函数里面有yield是一个生成器，必须next一下才会执行
    r = con2.__next__()
    n = 0
    while n < 5:
        print('\33[32;1m[producer]\33[0m is makeing baozi %s' % n)
        n += 1
        con.send(n)
        con2.send(n)

if __name__ == '__main__':
    con = consumer('C1')
    con2 = consumer('C2')
    p = producer()







#
# def foo():
#     print("starting...")
#     while True:
#         res = yield 4
#         print("res:", res)
# g = foo()
# print(next(g))
# print("*"*20)
# print(g.send(7))